﻿#include "jsonreader.h"

JsonReader::JsonReader(const QString &input)
{
    array = QJsonDocument::fromJson(input.toLocal8Bit()).array();
    qDebug() << QJsonDocument::fromJson(input.toLatin1()).isArray();

}

JsonReader::~JsonReader()
{

}

int *JsonReader::getData()
{
    if(array.isEmpty()) {
        return nullptr;
    } else {
        int count = array.count();
        qDebug() << count;
        int *outData = new int[count];
        int *temp = outData;
        for(auto iterator = array.constBegin(); iterator != array.constEnd(); iterator++) {
            *temp = (*iterator).toInt();
            temp++;
        }
        return outData;
    }
}
